package com.fw.ui.util;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;

import java.util.Locale;

import org.springframework.context.annotation.Scope;

import com.fw.service.bean.SessionInfoBean;
import com.fw.ui.bean.AuthenticationBean;
import com.vaadin.server.VaadinServletService;

@org.springframework.stereotype.Component
@Scope(SCOPE_PROTOTYPE)
public class SessionInfoUtils {

    public SessionInfoBean setSessionInfoDetails(SessionInfoBean sessionInfoBean, AuthenticationBean authenticationBean, Locale locale) {
	sessionInfoBean.setLocale(locale);
	sessionInfoBean.setLoginRoleId(authenticationBean.getRoleId());
	sessionInfoBean.setLoginRoleName(authenticationBean.getRoleName());
	sessionInfoBean.setLoginUserId(authenticationBean.getUserId());
	sessionInfoBean.setLoginUsername(authenticationBean.getUsername());
	sessionInfoBean.setUserIp(VaadinServletService.getCurrentRequest().getRemoteAddr());
	return sessionInfoBean;
    }

}
